
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>设备编辑</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
</head>
<body>
    <div class="layui-fluid accountForm">
        <form class="layui-form" action="" lay-filter="accountEditForm">
            <div class="record-formtitle">管理信息</div>
            <div class="basicInfo clearfix">
                <div class="layui-form-item">
                    <label class="layui-form-label">资材编号</label>
                    <div class="layui-input-block">
                        <input type="text" name="etCode"  autocomplete="off" class="layui-input" lay-verify="required">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">资材大类编号</label>
                    <div class="layui-input-block">
                        <input type="text" name="domain"  autocomplete="off" class="layui-input" lay-verify="required" disabled>
                        <!-- <select name="domain" lay-filter='majorListFilter' lay-verify="required" id="majorList">
                            <option value=""></option>
                        </select> -->
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">资材小类编号</label>
                    <div class="layui-input-block">
                        <input type="text" name="systemName"  autocomplete="off" class="layui-input" lay-verify="required" disabled>
                        <!-- <select name="systemName"  lay-filter='systemListFilter' autocomplete="off" id="systemList">
                            <option value=""></option>
                        </select> -->
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">设备类型</label>
                    <div class="layui-input-block">
                        <input type="text" name="etType"  autocomplete="off" class="layui-input" lay-verify="required" disabled>
                        <!-- <select name="etType" lay-filter='equipmentListFilter' autocomplete="off" id="equipmentList">
                            <option value="">请选择</option>
                        </select> -->
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">资材名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="etName"  autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">资材描述</label>
                    <div class="layui-input-block">
                        <input type="text" name="etComment"  autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">创建人编号</label>
                    <div class="layui-input-block">
                        <input type="text" name="createdId"  autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">创建人姓名</label>
                    <div class="layui-input-block">
                        <input type="text" name="createdName"  autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">创建时间</label>
                    <div class="layui-input-block">
                        <!-- <i class="layui-icon layui-icon-date"></i> -->
                        <input type="text" name="createdTime"  autocomplete="off" class="layui-input" id="installRepairDate">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">所属单位</label>
                    <div class="layui-input-block">
                        <input type="text" name="owner"  autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="record-formtitle">基础信息</div>
            <div class="basicInfo clearfix">
                <div class="layui-form-item">
                    <label class="layui-form-label">规格型号</label>
                    <div class="layui-input-block">
                        <input type="text" name="etModel"  autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">供应商</label>
                    <div class="layui-input-block">
                        <input type="text" name="etSupplier"  autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">制作商</label>
                    <div class="layui-input-block">
                        <input type="text" name="etProducer"  autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">出厂日期</label>
                    <div class="layui-input-block">
                        <i class="layui-icon layui-icon-date"></i>
                        <input type="text" name="dateOfProduction"  autocomplete="off" class="layui-input" id="productionDate">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">保修期至</label>
                    <div class="layui-input-block">
                        <i class="layui-icon layui-icon-date"></i>
                        <input type="text" name="guaranteePeriod"  autocomplete="off" class="layui-input" id="guaranteeDate">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">产品序列号</label>
                    <div class="layui-input-block">
                        <input type="text" name="serialNum"  autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">专业类别编号</label>
                    <div class="layui-input-block">
                        <input type="text" name="professionalId"  autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">额定电压</label>
                    <div class="layui-input-block">
                        <input type="text" name="voltage"  autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">额定功率</label>
                    <div class="layui-input-block">
                        <input type="text" name="power"  autocomplete="off" class="layui-input" >
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">使用寿命</label>
                    <div class="layui-input-block">
                        <input type="text" name="life"  autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="record-formtitle">安装信息</div>
            <div class="basicInfo clearfix">
                <div class="layui-form-item">
                    <label class="layui-form-label">线路编号</label>
                    <div class="layui-input-block">
                        <select name="lineId" id="inlineId" lay-filter='inlineIdFilter'>
                            <option value="">请选择</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">所属站点</label>
                    <div class="layui-input-block">
                        <select name="stationName" id="inetStation">
                            <option value="">请选择</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">安装位置</label>
                    <div class="layui-input-block">
                        <input type="text" name="installLocation"  autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">安装日期</label>
                    <div class="layui-input-block">
                        <i class="layui-icon layui-icon-date"></i>
                        <input type="text" name="installDate"  autocomplete="off" class="layui-input" id="repairDate" value="">
                    </div>
                </div>
            </div>
            <div class="record-formtitle">维护信息</div>
            <div class="basicInfo clearfix">
                <div class="layui-form-item">
                    <label class="layui-form-label">是否维修计划</label>
                    <div class="layui-input-block">
                        <select name="isPlan" disabled>
                            <option value="1">是</option>
                            <option value="0">否</option>
                        </select>
                    </div>
                </div>
                <div class="itemShow">
                    <div class="layui-form-item">
                        <label class="layui-form-label">首次维修计划日期</label>
                        <div class="layui-input-block">
                            <i class="layui-icon layui-icon-date"></i>
                            <input type="text" name="maintainfirstTime"   autocomplete="off" class="layui-input" id="firstRepairDate" disabled>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">本次维护计划日期</label>
                        <div class="layui-input-block">
                            <i class="layui-icon layui-icon-date"></i>
                            <input type="text" name="maintainthisTime" autocomplete="off" class="layui-input" id="thisRepairDate" disabled>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">下次维护计划日期</label>
                        <div class="layui-input-block">
                            <i class="layui-icon layui-icon-date"></i>
                            <input type="text" name="maintainnextTime" autocomplete="off" class="layui-input" id="nextRepairDate" disabled>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">距离下次维修计划间隔（天）</label>
                        <div class="layui-input-block">
                            <input type="text" name="intervalDay" autocomplete="off" class="layui-input" disabled>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">距离下次维护计划时间（天）</label>
                        <div class="layui-input-block">
                            <input type="text" name="maintainnextDay" autocomplete="off" class="layui-input" disabled>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-hide">
                <input type="button" lay-submit lay-filter="layuiadmin-app-form-submit" id="layuiadmin-app-form-submit" value="确认添加">
                <input type="button" lay-submit lay-filter="layuiadmin-app-form-edit" id="layuiadmin-app-form-edit" value="确认编辑">
              </div>
        </form>
    </div>
<script src='../../layuiadmin/modules/jTools.js'></script>
<script src="../../layuiadmin/layui/layui.js"></script>
<script>
    function initData(dataa){
        layui.config({
            base: '../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
            , my_send: '../myModules/my_send'
        }).use(['index', 'equipment','my_send','laydate'], function(){
            var $ = layui.$
                ,form = layui.form
                ,table = layui.table
                , laydate = layui.laydate
                ,my_send = layui.my_send
                ,formfMcId = jTools.getQuery('fMcId')
                ,http_proxy = layui.http_proxy;
                $.ajax({
                    type : "get",
                    async : false, //异步执行
                    url : http_proxy("/equipmentLAIM/getTableCodeAndValue/")+ dataa.eid,
                    dataType : "json", //返回数据形式为json
                    success : function(data) {
                        $.each(data.lineList,function(index,item){
                            $('#inlineId').append(new Option(item.lineName,item.lineId));
                        })
                        $.each(data.stationList,function(index,item){
                            $('#inetStation').append(new Option(item.stationName,item.stationId));
                        })
                        var mcAttrListData = data.mcAttrList[0];
                        function timestampToTime(timestamp) {
                            var date = new Date(timestamp);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
                            var Y = date.getFullYear() + '-';
                            var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
                            var D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()) + ' ';
                            return Y+M+D;
                        }
                        var createdTime = timestampToTime(mcAttrListData.createdTime),
                        dateOfProduction = timestampToTime(mcAttrListData.dateOfProduction),
                        guaranteePeriod = timestampToTime(mcAttrListData.guaranteePeriod),
                        installDate = timestampToTime(mcAttrListData.installDate);
                        form.val("accountEditForm", {
                            eid:mcAttrListData.eid,
                            etCode: mcAttrListData.etCode,
                            domain: mcAttrListData.domain,
                            systemName: mcAttrListData.systemName,
                            etName:mcAttrListData.etName,
                            etType:mcAttrListData.etType,
                            etComment:mcAttrListData.etComment,
                            createdId: mcAttrListData.createdId,
                            createdName:mcAttrListData.createdName,
                            createdTime:createdTime,
                            owner: mcAttrListData.owner,
                            etModel: mcAttrListData.etModel,
                            etSupplier: mcAttrListData.etSupplier,
                            etProducer: mcAttrListData.etProducer,
                            dateOfProduction: dateOfProduction,
                            guaranteePeriod: guaranteePeriod,
                            serialNum: mcAttrListData.serialNum,
                            professionalId: mcAttrListData.professionalId,
                            voltage:mcAttrListData.voltage,
                            power: mcAttrListData.power,
                            life: mcAttrListData.life,
                            stationName: mcAttrListData.stationName,
                            installLocation: mcAttrListData.installLocation,
                            installDate: installDate,
                            planned: mcAttrListData.planned,
                            etMaintainPlan:mcAttrListData.etMaintainPlan,
                            // lineId:mcAttrListData.pzLine.lineId,
                            lineId:data.lineList[0].lineId,
                            isPlan:mcAttrListData.etMaintainPlan.isPlan,
                            intervalDay:mcAttrListData.etMaintainPlan.intervalDay,
                            maintainfirstTime:mcAttrListData.etMaintainPlan.maintainfirstTime,
                            maintainnextDay:mcAttrListData.etMaintainPlan.maintainnextDay,
                            maintainnextTime:mcAttrListData.etMaintainPlan.maintainnextTime,
                            maintainthisTime:mcAttrListData.etMaintainPlan.maintainthisTime
                        });
                        form.render('select');
                    }
                })
                
            // $.ajax({
            //     type : "get",
            //     async : false, //异步执行
            //     url : http_proxy("/equipmentLAIM/getTableCodeAndValue/")+ dataa.eid,
            //     // url : http_proxy("/mcIn/getTableCodeAndValue?fMcId=")+ formfMcId + '&fProductId=' + dataa.productId,
            //     dataType : "json", //返回数据形式为json
            //     success : function(data) {
            //         for (var j = 0; j < data.mcAttrList.length; j++) {
            //             var labelName =  '<label class="layui-form-label">'+data.mcAttrList[j].fCaName+'</label>';
            //             var inputValue = data.mcAttrList[j].fCaCodeValue === null ? "": data.mcAttrList[j].fCaCodeValue;
            //             if(data.mcAttrList[j].fCaFieldType==2){
            //                 if(data.mcAttrList[j].fCaCode == 'STATION_ID'){
            //                     var $html = "";
            //                     $.each(data.stationList, function (index, item) {
            //                         $html += "<option value='" + item.stationId + "'>" + item.stationName + "</option>";
            //                     });
            //                     str+='<div class="layui-form-item">' + labelName +
            //                         '<div class="layui-input-block">' +
            //                          '<select name="STATION_ID">' + $html+ '</select>' +
            //                             '</div>' +
            //                         '</div>'
            //                 }else if (data.mcAttrList[j].fCaCode == 'IS_MAINTENANCE_PLAN') {
            //                     str+='<div class="layui-form-item">'+ labelName +
            //                             '<div class="layui-input-block">' +
            //                                 '<select name="IS_MAINTENANCE_PLAN" lay-filter="IS_MAINTENANCE_PLAN">' +
            //                                     '<option value="1">是</option>' +
            //                                     ' <option value="0">否</option>' +
            //                                 '</select>'+
            //                             '</div>' +
            //                         '</div>'
            //                         form.on('select(IS_MAINTENANCE_PLAN)', function(datat){
            //                             if (datat.value==1){
            //                                 $('.itemShow').show();
            //                             }else {
            //                                 $('.itemShow').hide();
            //                             }
            //                         })
            //                 }else if (data.mcAttrList[j].fCaCode == 'LINE_ID'){
            //                     var $html = "";
            //                     $.each(data.lineList, function (index, item) {
            //                         $html += "<option value='" + item.lineId + "'>" + item.lineName + "</option>";
            //                     });
            //                     str+='<div class="layui-form-item">' +
            //                         labelName +
            //                         '<div class="layui-input-block">' +
            //                         '<select name="LINE_ID" id="lineId" lay-filter="lineId">' + $html+ '</select>' +
            //                         '</div>' +
            //                         '</div>'
            //                 }
            //                 else if(data.mcAttrList[j].fCaShowName=='距离下次维护计划时间（天）'||data.mcAttrList[j].fCaShowName=='创建人编号'||data.mcAttrList[j].fCaShowName=='创建人姓名'||data.mcAttrList[j].fCaShowName=='维修间隔天数'){
            //                     str +='<div class="layui-form-item itemShow">'+
            //                         labelName
            //                         +' <div class="layui-input-block">'+
            //                         '<input type="text" name="'+data.mcAttrList[j].fCaCode+'"  autocomplete="off" class="layui-input" id="repairDate" value="'+inputValue+'">'
            //                         +'</div>'+'  </div>'
            //                 }else{
            //                     str +='<div class="layui-form-item">'+
            //                         labelName
            //                         +' <div class="layui-input-block">'+
            //                         '<input type="text" name="'+data.mcAttrList[j].fCaCode+'"  autocomplete="off" class="layui-input" id="repairDate" value="'+inputValue+'">'
            //                         +'</div>'+'  </div>'
            //                 }
            //             }
            //             else if(data.mcAttrList[j].fCaFieldType==3||data.mcAttrList[j].fCaFieldType==4){
            //                     if(data.mcAttrList[j].fCaShowName=='首次维修计划日期'||data.mcAttrList[j].fCaShowName=='本次维护计划日期'||data.mcAttrList[j].fCaShowName=='预计下次维护计划日期'||data.mcAttrList[j].fCaShowName=='创建时间'){
            //                         str +='<div class="layui-form-item itemShow">'+labelName
            //                     +' <div class="layui-input-block">'+'<i class="layui-icon layui-icon-date"></i>'+
            //                     '<input type="text" name="'+data.mcAttrList[j].fCaCode+'" class="layui-input loan-date" value="'+inputValue+'">'
            //                     +'</div>'+'</div>'
            //                     }else{
            //                         str +='<div class="layui-form-item">'+labelName
            //                     +' <div class="layui-input-block">'+'<i class="layui-icon layui-icon-date"></i>'+
            //                     '<input type="text" name="'+data.mcAttrList[j].fCaCode+'" class="layui-input loan-date" value="'+inputValue+'">'
            //                     +'</div>'+'</div>'
            //                     }
            //             }
            //         }
            //         str+='<div class="layui-form-item layui-hide">' +
            //             '<input type="button" lay-submit lay-filter="layuiadmin-app-form-submit" id="layuiadmin-app-form-submit" value="确认添加">' +
            //             '<input type="button" lay-submit lay-filter="layuiadmin-app-form-edit" id="layuiadmin-app-form-edit" value="确认编辑">' +
            //             '</div>'
            //         $('.layui-form').append(str);
            //         form.render();
            //     },
            //     error : function(errorMsg) {
            //         alert("请求数据失败");
            //     }
            // });
            // lay('.loan-date').each(function(){
            //     laydate.render({
            //         elem: this
            //         ,trigger: 'click'
            //     });
            // });
            // form.val('layuiadmin-form-role',{
            //     'STATION_ID':dataa.STATIONID,
            //     'LINE_ID':dataa.lineId,
            // })
        })
    }
</script>
</body>
</html>
